home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / earthlink / nscomm / java40.jar / netscape / debug / ThreadState.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  2.5 KB  |  113 lines

  1. package netscape.debug;
  2.  
  3. public class ThreadState {
  4.    private Thread thread;
  5.    private boolean valid;
  6.    private boolean runningHook;
  7.    private boolean resumeWhenDone;
  8.    private int status;
  9.    private int continueState;
  10.    StackFrameInfo[] stack;
  11.    private Object returnValue;
  12.    private Throwable currentException;
  13.    private ThreadHook savedHook;
  14.    private int currentFramePtr;
  15.    private ThreadState previous;
  16.    public static final int THR_STATUS_UNKNOWN = 1;
  17.    public static final int THR_STATUS_ZOMBIE = 2;
  18.    public static final int THR_STATUS_RUNNING = 3;
  19.    public static final int THR_STATUS_SLEEPING = 4;
  20.    public static final int THR_STATUS_MONWAIT = 5;
  21.    public static final int THR_STATUS_CONDWAIT = 6;
  22.    public static final int THR_STATUS_SUSPENDED = 7;
  23.    public static final int THR_STATUS_BREAK = 8;
  24.    public static final int DEBUG_STATE_DEAD = 1;
  25.    public static final int DEBUG_STATE_RUN = 2;
  26.    public static final int DEBUG_STATE_RETURN = 3;
  27.    public static final int DEBUG_STATE_THROW = 4;
  28.  
  29.    public static native ThreadState getThreadState(Thread var0) throws InvalidInfoException;
  30.  
  31.    public Thread getThread() {
  32.       return this.thread;
  33.    }
  34.  
  35.    public boolean isValid() {
  36.       return this.valid;
  37.    }
  38.  
  39.    public boolean isRunningHook() {
  40.       return this.runningHook;
  41.    }
  42.  
  43.    public int getStatus() {
  44.       return this.status;
  45.    }
  46.  
  47.    public native int countStackFrames() throws InvalidInfoException;
  48.  
  49.    public native StackFrameInfo getCurrentFrame() throws InvalidInfoException;
  50.  
  51.    public synchronized StackFrameInfo[] getStack() throws InvalidInfoException {
  52.       if (this.stack == null) {
  53.          this.stack = new StackFrameInfo[this.countStackFrames()];
  54.       }
  55.  
  56.       if (this.stack.length == 0) {
  57.          return this.stack;
  58.       } else {
  59.          StackFrameInfo var1 = this.getCurrentFrame();
  60.          this.stack[this.stack.length - 1] = var1;
  61.  
  62.          for(int var2 = this.stack.length - 2; var2 >= 0; --var2) {
  63.             var1 = var1.getCaller();
  64.             this.stack[var2] = var1;
  65.          }
  66.  
  67.          return this.stack;
  68.       }
  69.    }
  70.  
  71.    public void leaveSuspended() {
  72.       this.resumeWhenDone = false;
  73.    }
  74.  
  75.    public synchronized void resume() {
  76.       if (this.runningHook) {
  77.          this.resumeWhenDone = true;
  78.       } else {
  79.          this.resume0();
  80.       }
  81.    }
  82.  
  83.    private native void resume0();
  84.  
  85.    public int getContinueState() {
  86.       return this.continueState;
  87.    }
  88.  
  89.    public Object getReturnValue() throws IllegalStateException {
  90.       if (this.continueState != 3) {
  91.          throw new IllegalStateException("no value being returned");
  92.       } else {
  93.          return this.returnValue;
  94.       }
  95.    }
  96.  
  97.    public Throwable getException() throws IllegalStateException {
  98.       if (this.continueState != 4) {
  99.          throw new IllegalStateException("no exception throw in progress");
  100.       } else {
  101.          return this.currentException;
  102.       }
  103.    }
  104.  
  105.    public void setThreadHook(ThreadHook var1) {
  106.       this.savedHook = var1;
  107.    }
  108.  
  109.    public ThreadHook getThreadHook() {
  110.       return this.savedHook;
  111.    }
  112. }
  113.